import { IsString, IsOptional, IsBoolean, IsObject, IsArray, ValidateNested, IsNumber } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { PartialType } from '@nestjs/swagger';

export class WorkflowStatsDto {
    @IsOptional()
    @IsNumber()
    uses: number = 0;

    @IsOptional()
    @IsNumber()
    likes: number = 0;

    @IsOptional()
    @IsNumber()
    views: number = 0;
}

export class CreateWorkflowDto {
    @ApiProperty({ description: '工作流名称' })
    @IsString()
    name: string;

    @ApiProperty({ description: '工作流描述' })
    @IsString()
    @IsOptional()
    description?: string;

    @ApiProperty({ description: '作者' })
    @IsString()
    @IsOptional()
    author?: string = 'anonymous';

    @ApiProperty({ description: '分类' })
    @IsString()
    category: string;

    @ApiProperty({ description: '预览图URL' })
    @IsString()
    thumbnail: string;

    @ApiProperty({ description: 'ComfyUI工作流配置' })
    @IsObject()
    comfyuiJson: Record<string, any>;

    @ApiProperty({ description: '标签', type: [String] })
    @IsArray()
    @IsString({ each: true })
    tags: string[] = [];

    @ApiProperty({ description: '是否公开' })
    @IsBoolean()
    @IsOptional()
    isPublic?: boolean = false;

    @ApiProperty({ description: '版本号' })
    @IsString()
    @IsOptional()
    version?: string = '1.0.0';

    @ApiProperty({ description: '统计信息' })
    @IsOptional()
    @ValidateNested()
    @Type(() => WorkflowStatsDto)
    stats?: WorkflowStatsDto;
}

export class UpdateWorkflowDto extends PartialType(CreateWorkflowDto) { } 